﻿using UnityEngine;
using System.Collections;

public class TextController
{
    static public string GetStringWithId(string LocalizeId)
    {        
        if (Localization.dictionary.ContainsKey(LocalizeId))
        {
            //string[] idStrings = Localization.dictionary[LocalizeId];
            //return idStrings[(int)UserData.Instance.m_Language];

            return Localization.Get(LocalizeId);
        }

        return LocalizeId;
    }

    static public string GetItemDefine(Item item)
    {
        if (item == null)
            return null;

        return GameData.Inst.ItemDefineDic[item.itemInfo.modelID];     
    }
       

	static public string GetItemDefine(DItem item)
	{
		if (item == null)
			return null;
		
		return GameData.Inst.ItemDefineDic[item.modelID];     
	}

	static public string GetItemDefine(int itemId)
	{
		foreach(DItem itemInfo in GameData.Inst.item)
		{
			if( itemInfo.itemID == itemId )
			{
				return GameData.Inst.ItemDefineDic[itemInfo.modelID];     
			}
		}

		return "";
	}

    static public string GetMemberModelDefine(MemberModel model)
    {
        return GameData.Inst.ModelDefineDic[model.model];
    }

    static public string GetItemName(Item item)
    {
        return TextController.GetStringWithId(string.Format("itemName{0}", item.itemInfo.itemID));
    }

	static public string GetItemName(DItem item)
	{
		return TextController.GetStringWithId(string.Format("itemName{0}", item.itemID));
	}

	static public string GetItemName(int itemId)
	{
		return TextController.GetStringWithId(string.Format("itemName{0}", itemId));
	}

    //string.Format("trait{0}", UserData.Instance.userModel.m_PartySincSuccessList[i].targetAttribute)

    static public string GetItraitName(int attribute)
    {
        return TextController.GetStringWithId(string.Format("trait{0}", attribute));
    }

	static public string GetRegionName(int regionId)
	{
		return Localization.Get (string.Format("region{0}", regionId.ToString()));
	}

	static public string GetBossName(int BossId)
	{
		return Localization.Get (string.Format("bossName{0}", BossId.ToString()));
	}
}